<?php
define('IN_ADMIN',True);
require('include/common.php');

$do = getGP('do','G');

if ( check_submit('dosubmit') ) {
	
	$errmsg = array();
	initGP(array('username', 'password', 'vdcode','remember'), 'P');
	
	if ( strlen($username) < 3 || strlen($username) > 20 ) {
		$errmsg[] = '用户名长度必须在3-20字节之间。';
	} elseif ( !is_username($username) ) {
		$errmsg[] = '用户名中含有非法字符。';
	}
	
	if ( strlen($password) < 6 ) $errmsg[] = '密码长度不能小于6个字节。';
	if ( get_config('user','login_vdcode') ) {
		session_start();
		if ( strtolower($vdcode) != $_SESSION['vdcode'] ) $errmsg[] = '验证码不正确。';
		unset($_SESSION['vdcode']);
	}
	
	if (count($errmsg)) show_msg($errmsg, 'login.php');
	$flag = $_USER->login($username, $password, $remember);
	if ( $flag == 1) {
		goto_page('admin.php');
	} elseif ( $flag == -3 ) {
		show_msg('登录失败，你的帐号尚未通过审核。', 'login.php');
	} else {
		show_msg('登录失败，用户名或密码错误。', 'login.php');
	}

}

if ($do == "logout") {

	$_USER->logout();
	show_msg('你已经安全退出登录，现在转到首页...','./');

} else {

	if ( $_USER->id ) {
	goto_page('admin.php');

}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <META content="MSHTML 6.00.2800.1276" name=GENERATOR>
     <META http-equiv=Content-Type content="text/html; charset=utf-8">
    <META http-equiv=Content-Style-Type content=text/css>
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<title>天生创想 网络OA办公系统</title>
<style type="text/css">
*{padding:0px;margin:0px;}
body{
   background:#d5e4f2 url('themes01/default/images/bg_login.png') left top repeat-x;
   font-size:12px;
   color:#383838;
}
.update_tips{position:absolute;left:10px;top:10px;color:#FFFFFF;}
#logo{
   margin:0px auto;
   margin-top:100px;
   padding-left:283px;
   padding-top:247px;
   width:498px;
   height:260px;
   background:url('themes01/default/images/logo.png') left top no-repeat;
}
#logo #form{
   width:245px;
   height:96px;
   padding-left:10px;
}
#logo #form .left{
   float:left;
   width:350px;
}
#logo #form .left div{
   height:32px;
   text-align:left;
}
#logo #form .right{
   float:left;
   width:62px;
}

#logo .msg{
   width:345px;
   padding-top:15px;
   line-height:20px;
   text-align:center;
}

input.text{
   border:1px #cccccc solid;
   padding:0px 5px;
   width:168px;
   height:25px;
   line-height:25px;
}
select{
   width:140px;
   height:22px;
}
input.submit:hover{
   background-position:0 -57px;
}

</style>
</head>

<body bgcolor="#e3e1d5" style="overflow:hidden;margin: 0px;padding: 0px;" onLoad=" load();">

<form name="login" method="post" target="_top" action="login.php">
<input type="hidden" name="dosubmit" value="yes" />
<div id="logo">
   <div id="form">
      <div class="left">
         <div class="user" style="height:40px;"><input type="text" class="text" name="username" maxlength="20" onmouseover="this.focus()" onfocus="this.select()" value=""></div>
         <div class="pwd" style="height:40px;"><input type="password" class="text" name="password" onmouseover="this.focus()" onfocus="this.select()" value=""></div>
        <div >
          <input type="image" name="submit" src="themes01/default/images/login.png">
          
        </div>
      </div>
      <div class="right">
         
      </div>
   </div>
</div>
</form>
</body>

</html>

